package cn.qingyun.gis.modules.enterprise.controller;


import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.enterprise.entity.Grid;
import cn.qingyun.gis.modules.enterprise.service.IGridService;
import cn.qingyun.gis.modules.init.system.base.controller.BasicController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;


/**
 * <p>
 * 区划数据表 前端控制器
 * </p>
 *
 * @author skb
 * @since 2024-03-29
 */
@RestController
@RequestMapping("/grid")
@Api(value = "网格数据操作", tags = {"网格数据操作"})
@Slf4j
public class GridController {

    @Autowired
    private IGridService gridService;

    @ApiOperation("获取用户权限下地区数据")
    @GetMapping("/regionData")
    public Result<?> getRegionList() {
        return Result.okData(gridService.getRegionList());
    }

    @ApiOperation("获取所有网格数据")
    @GetMapping("/gridData")
    public Result<?> getGridList(@RequestParam @NotNull(message = "区县编码不能为空") String code) {
        return Result.okData(gridService.getGridList(code));
    }

    @ApiOperation("获取所有网格数据")
    @GetMapping("/treeList")
    public Result<?> getGridList() {
        return Result.okData(gridService.getTreeList());
    }
    @ApiOperation("获取wkt数据")
    @GetMapping("/wkt")
    public Result<?> getWkt(@RequestParam String code){
        return Result.okData(gridService.getWktByCode(code));
    }



}
